import formBuilder from "@/comps/form/formBuilder";
import api from "./api";
import apiNeedStatus from "@/pages/v1/erp/NeedStatus/js/apiNeedStatus";
import apiDepartment from "@/pages/v1/erp/Department/js/apiDepartment";
import apiEmp from "@/pages/v1/erp/Emp/js/apiEmp";
/*
fb.addText("sn","单据编号",3)
fb.addText("title","单据主题",3)
fb.addText("status","状态",3)
fb.addText("isConfirm","是否生效",3)
fb.addText("isCancel","是否取消",3)
fb.addText("isClose","是否关闭",3)
fb.addText("formAt","制单时间",3)
fb.addText("confirmAt","生效时间",3)
fb.addText("needAt","需求时间",3)
fb.addText("formEmp","制单人",3)
fb.addText("createEmp","创建人",3)
fb.addText("needEmp","需求人",3)
fb.addText("needDept","需求部门",3)
fb.addText("note","备注",3)

* */
export default {
    main:function () {
        let fb = formBuilder()
        fb.setLabelWidth(100)

        fb.addText("sn","单据编号",3)
        fb.addText("title","单据主题",6)
            .setRules([fb.R.notNull("单据编号不能为空")])
        fb.addCascade("statusId","状态",3)
            .setApi(apiNeedStatus.urlTree)
            .setRules([fb.R.notNull("请设置状态")])

        fb.addSearch("needEmpId","需求人",3)
            .setApi(apiEmp.urlChoice).setApiSearchKeys(["name__regex","phone__regex"])
        fb.addDateTime("needAt","需求时间",3)
            .setDateTypeDate()
        fb.addCascade("needDeptId","需求部门",3)
            .setApi(apiDepartment.urlTree)
        fb.addBlank("a","",3)

        fb.addText("note","备注",12)
            .setTextMulti(true)
            .setTextRows(3)
        fb.addSearch("formEmpId","制单人",3)
            .setApi(apiEmp.urlChoice).setApiSearchKeys(["name__regex","phone__regex"])
        fb.addDateTime("formAt","制单时间",3)
            .setDateTypeDate()
        return fb
    },
    tree:function () {
        let fb = formBuilder()
        fb.setLabelWidth(100)

        fb.addCascade("parentId").setLabel("上级分类").setSpan(3)
            .setApi(api.urlTree)

        fb.addText("name").setSpan(6).setLabel("分类名称")
            .setRules([fb.R.notNull("名称不能为空")])

        fb.addText("sort").setSpan(3).setLabel("排序").setTypeNumber()
        return fb
    },
    other:function () {
        let fb = formBuilder()
        fb.setLabelWidth(100).setLabelPosition("right")

        return fb
    }
}